package com.xd.service.admin.XTGLY.impl;

import com.xd.Mapper.ProductMapper;
import com.xd.Result.CommonResult;
import com.xd.erroCode.Errcode;
import com.xd.service.admin.XTGLY.AdminUpdateProductService;
import com.xd.service.admin.XTGLY.impl.BrandProductServiceImpl;
import com.xd.vo.productVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class updateProductServiceImpl implements AdminUpdateProductService {
    private final ProductMapper productMapper;

    @Autowired
    BrandProductServiceImpl brandProductService;

    public updateProductServiceImpl(ProductMapper productMapper) {
        this.productMapper = productMapper;
    }

    @Override
    public CommonResult updateProduct(productVo productVo) {
        CommonResult brandToADDProduct = brandProductService.getBrandToADDProduct(productVo);
        if (brandToADDProduct.isSuccess()){
        productMapper.update(productVo);
        return CommonResult.Success();
        }
        return CommonResult.error( Errcode.FAILED_UPDATE);
    }
}
